package com.study.example.login_regist;

import java.util.Scanner;

/**
* @Name: GuessGame
* @Description: 猜数字小游戏
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-1-16 下午4:16:00 
* @Version: V1.0
 */
public class GuessGame {

	public GuessGame() {
	}

	public static void start() {
		//产生一个随机数
		int number = (int) (Math.random() * 100) + 1 ;
		//定义一个统计变量
		int count = 0 ;
		while(true) {
			//键盘录入一个数据
			Scanner sc = new Scanner(System.in) ;
			System.out.println("请输入数据(1-100):");
			int guestNumber = sc.nextInt() ;
			count ++ ;
			//判断
			if(guestNumber > number) {
				System.out.println("你猜的数据" + guestNumber + "大了");
			} else if (guestNumber > number) {
				System.out.println("你猜的数据" + guestNumber + "小了");
			} else {
				System.out.println("恭喜你，" + count + "次就猜中了.");
				break ;
			}
		}
	}
	
}
